import { Bi } from "@/module-00-codebase/pkg-01-container";
export class Dict {
  public get(dictGroupName: string, dictCode: string): string;
  public get(dictGroupName: string): Map<string, string>;
  public get(dictGroupName: any, dictCode?: any) {
    if (!!dictCode) return this.get(dictGroupName).get(dictCode) || dictCode;
    else if (groupName_dictCode_dictValue_map.get(dictGroupName) === undefined) return groupName_dictCode_dictValue_map.set(dictGroupName, new Map()).get(dictGroupName);
    else return groupName_dictCode_dictValue_map.get(dictGroupName);
  }
}
export const initializing = async (dict: Dict) => {
  const res = await Bi.rpc.send({ resourceName: "innerDict", action: "getlist", loading: "Loading dictionary..." });
  res.data.list.forEach((item: DictObject) => dict.get(item.dictGroup.name).set(item.code, item.value));
};
export const dependencies = () => ["Rpc"];
const groupName_dictCode_dictValue_map = new Map<string, Map<string, string>>();
type DictObject = {
  code: string;
  dictGroup: { name: string };
  value: string;
};
